<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/plugs/aip-doc/api-doc.css">
    <link rel="stylesheet" href="//plugs/export/activereports/ar-js-ui.css">
    <link rel="stylesheet" href="//plugs/export/activereports/ar-js-designer.css">


    <script type="text/javascript" src="/plugs/aip-doc/api-doc.js"></script>
</head>
<script type="text/javascript">


    $(function () {
        $.getJSON("/json/api-doc.json",function (data) {
            $("#api").apiDocument({data: data,isTree:true});
        });
        //mock
        $(".aip-doc-container").on("click","#mock",function () {
            var data =  $("#api").apiDocument("mock");
            BootstrapDialog.show({title : "MOCK",html:"<pre><cod>"+JSON.stringify(data,null,4)+"</cod></pre>"});
        });
        //导出图片
        $(".aip-doc-container").on("click","#exportPhoto",function () {
            $("#api").bootstrapTreeTable("expandAll");
            html2canvas(document.querySelector("#api")).then(function (canvas) {
                var oImg = new Image();
                oImg.src = canvas.toDataURL();  // 导出图片
                //设置图片跨域访问
                oImg.crossOrigin = 'anonymous';
                $(oImg).css({ width: "100%", height: "100%",display: "none"});
                $(oImg).bootstrapViewer({ src: "src" });
                $(oImg).trigger("click");
            });
        });

        //导出图片
        $(".aip-doc-container").on("click","#exportPDF",function () {
            $("#api").bootstrapTreeTable("expandAll");

            setAvailableExports();

            return;

            var pageReport = new ARJS.PageReport();
            pageReport.load('/plugs/export/activereports/report.rdlx-json')
                .then(function() { return pageReport.run() })
                .then(function(pageDocument) { return PDF.exportDocument(pageDocument, settings) })
                .then(function(result) { result.download('arjs-pdf') });


            var options = {language:'zh'};
            var designer = new GC.ActiveReports.ReportDesigner.Designer("#api");
            designer.setReport({id: "/plugs/export/activereports/report.rdlx-json", displayName: "my report"});
           });
        });


    function setAvailableExports() {
        var viewer = new ActiveReports.Viewer("#api", {
            ExportsSettings: exportsSettings,
            language: "zh",
        });
        viewer.sidebarVisible = true;
        viewer.open(
            "/plugs/export/activereports/report.rdlx-json"
        );
        viewer.availableExports = ["pdf", "html", "xlsx"];
    }

</script>

<body>
<div class="aip-doc-container">
    <button id="mock" type="button" class="btn btn-dark">MOCK</button>
    <button id="exportPhoto" type="button" class="btn btn-dark">导出图片</button>
    <button id="exportPDF" type="button" class="btn btn-dark">导出PDF</button>
    <table  id="api"></table>
</div>


</body>
</html>